package com.hzw.saas.common.util;

import java.util.Random;

/**
 * @author zzl
 * @since 02/04/2021
 */
public class LangUtil {

    /**
     * 获取随机数字字符串
     *
     * @param base   首部字符串
     * @param length 随机字符串长度
     * @return 随机字符串
     */
    public static String getRandom(String base, int length) {
        if (base == null) {
            base = "";
        }
        if (base.length() > length) {
            base = base.substring(0, length);
        }

        StringBuilder str = new StringBuilder(base);
        Random random = new Random();
        for (int i = str.length(); i < length; i++) {
            str.append(random.nextInt(10));
        }
        return str.toString();
    }

}
